package pacificlms.Error;

import javax.swing.JOptionPane;

/**
 * ErrorDisplay exists to aid in debugging by sending all errors here to be displayed a flag can be raised to force the program to debug
 * @author brianhhh
 */
public class ErrorHandle {
    public static boolean BooleanDebug = false;
    public static boolean BooleanDebugWarnings = false;
    /**
     * Displays errors to the user via a dialog box and allows programmer to place breakpoints to debug errors
     * @param ErrorTitle is the value placed in the title field of the error/warning dialog
     * @param ErrorMessage is the message displayed to the user in the dialog box
     * @param Ex is the exception that was raised, this is only to aid in debugging
     * @param Error is a flag to determine if this is an error or simply a warning (errors are usually due to circumstances outside of users control)
     */
    public static void Display(String ErrorTitle, String ErrorMessage, Exception Ex, boolean Error)
    {
        int MessageType = JOptionPane.WARNING_MESSAGE;
        if (Error)
            MessageType = JOptionPane.ERROR_MESSAGE;
        
        if (BooleanDebug && Error || BooleanDebugWarnings && !Error)
        {
            int DebugOn = 0;
            DebugOn = 1;//set debug point here (Sadly it is not kept between sessions)
        }
        else
        {
            JOptionPane.showMessageDialog(null, ErrorMessage, ErrorTitle, MessageType);
        }
        System.err.println(Ex.toString());
        
    }
}
